public class RGBHandler {
	
	public int rgb(int[] rgbToFormat) {
		int rgb = (rgbToFormat[0] << 16);
		rgb = (rgbToFormat[1] << 8) + rgb;
		rgb = rgbToFormat[2] + rgb;
		return rgb;
	}
	
	public int[] rgb(int rgbToFormat) {
		int[] rgb = {-1,-1,-1};
		rgb[0] = (rgbToFormat & 0xff0000) >> 16;
		rgb[1] = (rgbToFormat & 0xff00) >> 8;
		rgb[2] = (rgbToFormat & 0xff);
		return rgb;
	}
	
	public boolean compareRGB(int[] rgbFromImage, int[] rgbToCompare, int threshold) {
		double difRed = Math.pow((rgbFromImage[0] - rgbToCompare[0]), 2);
		double difGreen = Math.pow((rgbFromImage[1] - rgbToCompare[1]), 2);
		double difBlue = Math.pow((rgbFromImage[2] - rgbToCompare[2]), 2);
		double dif = Math.sqrt(difRed + difGreen + difBlue);
		if (dif <= threshold) {
			return true;
		} else {
			return false;
		}
	}
}
